﻿@using ICDA.Web.Models
@model ICDA.Web.Models.AdminViewModel
@{
    ViewBag.Title = "UserActivity";
}
@{var colspan = Model.dtHelper.TotalDaysInMonth + 1;}
<div style="width: 100%; height: 30px; padding-bottom: 10px;">
    <table style=" float: left;">
        <tr>
            <td style="font-size: 13px; font-weight: bold;">
                Month:
            </td>
            <td>@Model.CurrentDateTime.ToString("y")
            </td>
        </tr>
    </table>
</div>
<div>
    <div style="width: 100%; font-size: 12px;">
        @*<div style="width: 50%; font-size: 12px; height: 50px; float: left;">
            @Html.ActionLink(" ", "LeaveMonth", new { id = (Model.PreviousYearDate.ToString("MMM-yyyy")) }, new { @class = "previousLink" })
        </div>
        <div style="width: 50%; font-size: 12px; height: 50px; float: left;">
            @Html.ActionLink(" ", "LeaveMonth", new { id = (Model.NextYearDate.ToString("MMM-yyyy")) }, new { @class = "nextLink" })
        </div>*@
    </div>
    <table style="width: 100%; font-size: 12px; border: 1px solid;" id="leaveUiTable" class="ui-widget">
        <thead class="ui-widget-header">
            <tr>
                <td>
                    <span class="table-header">Task name</span>
                </td>
                @{
                    for (int i = 1; i <= Model.dtHelper.TotalDaysInMonth; i++)
                    {
                    <td class="taskDateHeader">
                        <span class="table-header">@i</span>
                    </td>
                    }
                }
            </tr>
        </thead>
        <tbody class="ui-widget-content">
            @{
                foreach (KeyValuePair<string, List<ActivityViewModel>> items in Model.ActivityLayout)
                {  
                <tr>
                    <td colspan='@colspan' style=" border-bottom:1px solid #ccc; font-weight:bold; color:#575556" >
                        @items.Key
                    </td>
                </tr> 
                <tr>
                    <td colspan='@colspan' >
                        <table style="width: 100%; font-size: 12px;" id="taskTable">
                            @foreach (var task in items.Value.Select(t=>t.Task).Distinct())
                            {
                                <tr>
                                    <td style="color:#FA550F; font-weight:bold;">@task</td>
                                    
                                    @for (int i = 1; i <= Model.dtHelper.TotalDaysInMonth; i++)
                                    {
                                        <td style="background:#E3E3E4" class="taskDateHeader">
                                            @if (items.Value.Find(a => a.ActivityDate.Day == i && string.Equals(a.Task, task)) != null)
                                            {
                                                <span style="color:Black; font-weight:bold;">
                                                @items.Value.FirstOrDefault(a => a.ActivityDate.Day == i && string.Equals(a.Task, task)).TimeSpend
                                                </span>
                                            }
                                            else
                                            {
                                               
                                            }
                                        </td>
                                    }
                                </tr>
                            }
                        </table>
                    </td>
                </tr>
                <tr><td colspan='@colspan' style=" border-bottom:1px solid #ccc;"></td></tr>
                }
            }
        </tbody>
    </table>
</div>
